package com.isdust.jy.mbank;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.isdust.jy.mbank.activity.LoginActivity;
import com.isdust.jy.mbank.base.BaseActivity;
import com.isdust.jy.mbank.util.DialogHelp;
import com.isdust.jy.mbank.bean.EnvironmentBean;
import com.isdust.jy.mbank.view.spinner;
import com.isdust.zor.*;
import com.isdust.zor.core.util.DbUtil;
import com.isdust.zor.core.util.XmlUtils;

import java.io.ByteArrayInputStream;

public class TestActivity extends BaseActivity implements View.OnClickListener{

    String url="<environment><aqi_1>54</aqi_1><pm25>25</pm25><suggest>极少数敏感人群应减少户外活动</suggest><quality>良</quality><MajorPollutants>颗粒物(PM10)</MajorPollutants><o3>46</o3><co>0</co><pm10>56</pm10><so2>4</so2><no2>43</no2><time>17:00:00</time></environment>";
    Button[]buttons=new Button[5];
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.sp);
        spinner.drawables.add(bitmap);
        spinner.drawables.add(bitmap);
        spinner.drawables.add(bitmap);
        spinner.drawables.add(bitmap);
        setContentView(R.layout.activity_test);



        EnvironmentBean bean2 = XmlUtils.toBean(EnvironmentBean.class,new ByteArrayInputStream(url.getBytes()));
        Log.i("test===",bean2.toString());

        buttons[0] = (Button)findViewById(R.id.btn_1);
        buttons[1] = (Button)findViewById(R.id.btn_2);
        buttons[2] = (Button)findViewById(R.id.btn_3);
        buttons[3] = (Button)findViewById(R.id.btn_4);
        buttons[4] = (Button)findViewById(R.id.btn_5);
        for (Button button : buttons) {
            button.setOnClickListener(this);
        }




    }

    @Override
    protected boolean hasActionBar() {
        return false;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_1:
                Dialog dialog =  DialogHelp.getDialog(this).create();
                dialog.show();
                break;
            case R.id.btn_2:
                Dialog dialog2 =  DialogHelp.getWaitDialog(this,"正在登陆");
                dialog2.show();
                break;
            case R.id.btn_3:
                Dialog dialog1=DialogHelp.getMessageDialog(this,"xiaoxi").create();
                dialog1.show();
                break;
            case R.id.btn_4:
                Intent intent = new Intent(this, LoginActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_5:
                startActivity(new Intent(this, com.isdust.zor.MainActivity.class));
                break;
        }
    }
}
